package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    @Select("SELECT * FROM setmeal_dish WHERE dish_id = #{dishId}")
    SetmealDish findByDishId(Long dishId);

    List<Long> getSetmealIdsByDishIds(List<Long> dishIds);

    @Insert("INSERT INTO setmeal_dish(setmeal_id, dish_id, name, price, copies)" +
            "VALUES (#{setmealId}, #{dishId}, #{name}, #{price}, #{copies})")
    void insert(SetmealDish setmealDish);

    void insertAll(List<SetmealDish> setmealDishes);

    List<SetmealDish> getBySetmealId(Long id);

    @Delete("DELETE FROM setmeal_dish WHERE setmeal_id = #{setmealId}")
    void deleteBySetmealId(Long setmealId);

    void deleteBySetmealIds(List<Long> setmealIds);
}
